package f5transformation;

import flinkemp.Emp;
import flinkemp.EmpFun;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;


public class FlatMap {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        DataStreamSource<Emp> data = env.addSource(new EmpFun());
        data.print();
        data.flatMap(new FlatMapFunction<Emp, String>() {

            @Override
            public void flatMap(Emp emp, Collector<String> collector) {
                collector.collect("姓名:"+emp.eName);
                collector.collect("岗位:"+emp.job);
            }
        }).print();
        env.execute();
    }
}